package com.itcast.controller;

import com.itcast.domain.Book;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("books")
public class BookController {
    @PostMapping
    public String save(@RequestBody Book book){
        System.out.println("book save ...."+book);
        return "{'module':'book save success'}";
    }
    @GetMapping
    public List<Book> getAll(){
        List<Book> list=new ArrayList<>();
        Book book1 = new Book();
        book1.setType("sad");
        book1.setName("111");
        book1.setDescription("hao");
        list.add(book1);
        Book book2 = new Book();
        book2.setType("happy");
        book2.setName("222");
        book2.setDescription("huai");
        list.add(book2);
        return list;
    }
}
